//
//  VCOfEdit.m
//  project-A (pianke)
//
//  Created by dllo on 16/3/5.
//  Copyright © 2016年 scott. All rights reserved.
//

#import "VCOfEdit.h"
#import "CellofEdit.h"

#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT  [UIScreen mainScreen].bounds.size.height
@interface VCOfEdit ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,retain)UITableView *tabview;


@property (nonatomic,retain)UIImageView *image;

@property (nonatomic,retain)UILabel *label;

@property (nonatomic,retain)UIButton *button1;

@property (nonatomic,retain)UIButton *button2;

@end

@implementation VCOfEdit


-(void)dealloc{
    [_image release];
    [_label release];
    [_button1 release];
    [_button2 release];
    [_tabview release];
    [super dealloc];

    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"个人信息";
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self creetaview];
}

-(void)creetaview{
    
    self.tabview = [[UITableView alloc]init];
    self.tabview.frame = CGRectMake(0, 0, WIDTH, HEIGHT);
    [self.view addSubview:self.tabview];
    self.tabview.delegate = self;
    self.tabview.dataSource = self;
    
    self.tabview.backgroundColor = [UIColor whiteColor];
    
    self.tabview.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.tabview registerClass:[CellofEdit class] forCellReuseIdentifier:@"pool1"];
}



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 3;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    CellofEdit *cell = [tableView dequeueReusableCellWithIdentifier:@"pool1"];
    
    cell.name.textAlignment = 1 ;
    cell.name.font = [UIFont fontWithName:@"Arial-BoldMT" size:20];
    if(indexPath.row == 0){
        cell.name.text =@"头像";
        self.image = [[UIImageView alloc]init];
        self.image.frame = CGRectMake(WIDTH - 85, 15, 70, 70);
        self.image.image = [UIImage imageNamed:@"saber"];
        
        [cell addSubview:self.image];
        
        [self.image release];
        
    }else if (indexPath.row == 1){
        cell.name.text = @"昵称";
        
        self.label = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH * 0.5, 10, WIDTH * 0.5 - 15, 40)];
        [cell addSubview:self.label];
        self.label.textAlignment = 2;
        self.label.text = @"ゞ灬飝翔啲荷蘭亻亼╰→";
        [self.label release];
        
    }else if (indexPath.row == 2){
        cell.name.text = @"性别";
        self.button1 = [UIButton buttonWithType:UIButtonTypeCustom];
        
        self.button1.frame = CGRectMake(WIDTH * 0.5, 15, 30, 30);
        [cell addSubview:self.button1];
        self.button1.backgroundColor = [UIColor whiteColor];
        [self.button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        self.button1.layer.masksToBounds = YES;
        
        self.button1.layer.borderWidth = 1;
        self.button1.layer.borderColor = [[UIColor lightGrayColor]CGColor];
        self.button1.layer.cornerRadius = 15;
        
        [self.button1 addTarget:self action:@selector(nan) forControlEvents:UIControlEventTouchUpInside];
        
        [self.button1 setTitle:@"男" forState:UIControlStateNormal];
        
        [self.button1 release];
        
        self.button2 = [UIButton buttonWithType:UIButtonTypeCustom];
        
        self.button2.frame = CGRectMake(WIDTH * 0.8, 15, 30, 30);
        [cell addSubview:self.button2];
        
         self.button2.backgroundColor = [UIColor whiteColor];
        
        [self.button2 addTarget:self action:@selector(nv) forControlEvents:UIControlEventTouchUpInside];
        [self.button2 setTitle:@"女" forState:UIControlStateNormal];
         [self.button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        self.button2.layer.masksToBounds = YES;
        
        self.button2.layer.borderWidth = 1;
        self.button2.layer.borderColor = [[UIColor lightGrayColor]CGColor];
        self.button2.layer.cornerRadius = 15;
        
        [self.button2 release];
        
        
        
    }
    
    

    return cell;
}


-(void)nv{
    if (self.button2.backgroundColor == [UIColor whiteColor]&&self.button1.backgroundColor == [UIColor colorWithRed:0 green:0.5 blue:1 alpha:1]) {
        self.button1.backgroundColor = [UIColor colorWithRed:0 green:0.5 blue:1 alpha:1];
        
        
        self.button2.backgroundColor = [UIColor whiteColor];
    }else{
        
        self.button2.backgroundColor = [UIColor colorWithRed:0 green:0.5 blue:1 alpha:1];
        
        
        self.button1.backgroundColor = [UIColor whiteColor];
        
        
    }
}

-(void)nan{
    
    if (self.button2.backgroundColor == [UIColor whiteColor]&&self.button1.backgroundColor == [UIColor colorWithRed:0 green:0.5 blue:1 alpha:1]) {
        self.button2.backgroundColor = [UIColor colorWithRed:0 green:0.5 blue:1 alpha:1];
        
        
        self.button1.backgroundColor = [UIColor whiteColor];
    }else{
        
        self.button1.backgroundColor = [UIColor colorWithRed:0 green:0.5 blue:1 alpha:1];
        
        
        self.button2.backgroundColor = [UIColor whiteColor];
        
        
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    if (indexPath.row == 0) {
        return 100;
    }else{
        
        return 60;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
